package com.nbot.server.algorithm;

/**
 * 最大差值
 * wyzc 180618
 * 速率需要时间序列，待添加
 */

public class MaxDiffValueImpl {

    SetNumValue FormatResult = new SetNumValue();

    public float maxDiffVlaue(float[] data){

        float[] maxcontainer = data.clone();

        float[] mincontainer = data.clone();

        for (int i=0;i<maxcontainer.length-1;i++){
            maxcontainer[i+1] = Math.max(maxcontainer[i],maxcontainer[i+1]);
        }
        float max =  maxcontainer[maxcontainer.length-1];

        for (int i=0;i<mincontainer.length-1;i++){
            mincontainer[i+1] = Math.min(mincontainer[i],mincontainer[i+1]);
        }
        float min =  mincontainer[mincontainer.length-1];

        return FormatResult.setfloat(max-min,2);
    }
}